package com.diankangwo.dao.impl;

import com.diankangwo.constant.MessageType;
import com.diankangwo.dao.MessageDao;
import com.diankangwo.domain.Message;
import com.diankangwo.util.PageSupport;
import org.springframework.stereotype.Repository;

@Repository
public class MessageDaoImpl extends BaseDaoImpl<Message> implements MessageDao {

    @Override
    public PageSupport<Message> findByUid(String uid, int pageNo, int pageSize) {
        PageSupport<Message> messageList = new PageSupport<>();
        String hql = "from Message m where m.uid = ? or m.type =" + MessageType.system.getName();
        return findPagination(hql, pageNo, pageSize, uid);
    }

    @Override
    public PageSupport<Message> findByType(String uid, int type, int pageNo, int pageSize) {
        String hql = "from Message m where m.uid = ? and m.type =  ?";
        return findPagination(hql, pageNo, pageSize, uid, type);
    }


}
